package com.wangshouyu.log.config;

import com.wangshouyu.log.aop.AopSlowMethodLogClassAnnotationAdvisor;
import com.wangshouyu.log.aop.AopSlowMethodLogMethodAnnotationAdvisor;
import com.wangshouyu.log.aop.AopSlowMethodLogInterceptor;
import com.wangshouyu.log.print.LogPrint;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingClass;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author 王守钰
 * @description aop慢方法日志配置
 * @date 2020年7月23日10:36:36
 */
@Configuration
public class AopSlowMethodLogConfiguration extends AbstractLogConfiguration {

    @Bean
    @ConditionalOnMissingClass
    public AopSlowMethodLogInterceptor aopSlowMethodLogInterceptor(LogPrint logPrint){
        AopSlowMethodLogInterceptor aopSlowMethodLogInterceptor = new AopSlowMethodLogInterceptor();
        aopSlowMethodLogInterceptor.setLogPrint(logPrint);
        return aopSlowMethodLogInterceptor;
    }

    @Bean
    @ConditionalOnMissingClass
    public AopSlowMethodLogClassAnnotationAdvisor aopSlowMethodLogClassAnnotationAdvisor(AopSlowMethodLogInterceptor aopSlowMethodLogInterceptor){
        return new AopSlowMethodLogClassAnnotationAdvisor(aopSlowMethodLogInterceptor);
    }

    @Bean
    @ConditionalOnMissingClass
    public AopSlowMethodLogMethodAnnotationAdvisor aopSlowMethodLogMethodAnnotationAdvisor(AopSlowMethodLogInterceptor aopSlowMethodLogInterceptor){
        return new AopSlowMethodLogMethodAnnotationAdvisor(aopSlowMethodLogInterceptor);
    }
}
